package com.xianyu.open.restclient.factory;

import com.xianyu.open.restclient.proxy.ProxyCreator;
import org.springframework.beans.factory.FactoryBean;

/**
 *
 * @author bailinan
 * @date 2018/6/17
 */
public class ProxyFactoryBean implements FactoryBean<Object> {

    private Class<?> type;
    private ProxyCreator proxyCreator;

    public ProxyFactoryBean() {

    }

    @Override
    public Object getObject() throws Exception {
        return this.proxyCreator.createProxy(type);
    }

    @Override
    public Class<?> getObjectType() {
        return type;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    public void setType(Class<?> type) {
        this.type = type;
    }

    public void setProxyCreator(ProxyCreator proxyCreator) {
        this.proxyCreator = proxyCreator;
    }
}
